﻿using System;
using System.Text.RegularExpressions;

namespace Cloudy {
    public abstract class OnlineStorageServiceBase {


        public virtual long AvailableFreeSpace { get; protected set; }
        public virtual long Quota { get; protected set; }
        public virtual long UsedSize { get; protected set; }

        public abstract string ConnectionString { get; set; }
        public abstract string ServiceName { get; }
        public abstract string ServiceKey { get; }

        public static OnlineStorageServiceBase GetOnlineStorageService(string connectionString) {
            return null;
        }

        protected static string GetConnectionStringValue(string connectionString, string key){
            string result = null;

            if (!string.IsNullOrEmpty(connectionString) && !string.IsNullOrEmpty(key)) {
                var pattern = string.Format("{0}=(?<value>.*?)(;|$)", key);
                var m = Regex.Match(connectionString, pattern);
            }

            return result;
        }

        public abstract void UpdateInfo(Action<Exception> callback);
        public abstract void GetDirectoryNames(Action<Exception, string[]> callback);
    }
}
